import java.text.SimpleDateFormat;
import java.util.*;

public class ShangmiDemo implements Runnable{
    ThreadLocal<SimpleDateFormat> former = ThreadLocal.withInitial(()->new SimpleDateFormat("yyyyMMdd HH:mm:ss"));

    @Override
    public void run() {
        System.out.println("name = "+Thread.currentThread().getName()+" formatter="+former.get().toPattern());
        try{
            Thread.sleep(new Random().nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        former.set(new SimpleDateFormat());
        System.out.println("name = "+Thread.currentThread().getName()+" formatter="+former.get().toPattern());

    }

    static class taaa{
        static int x=10;
    }
    public static void main(String[] args) throws InterruptedException {
        ShangmiDemo obj = new ShangmiDemo();
        for (int i = 0; i < 10; i++) {
            Thread t = new Thread(obj,""+i);
            Thread.sleep(new Random().nextInt(1000));
            t.start();
        }
//        ArrayList<ArrayList<Integer>> res = new ArrayList<>();
////        Scanner scanner = new Scanner(System.in);
////        scanner.nextLine();
//        HashMap<Integer,Integer> h = new HashMap<>();
//        h.put(1,2);
//        h.put(2,2);
//        h.put(3,2);
//        Iterator<ArrayList<Integer>> iterator = res.iterator();
//        Set<Map.Entry<Integer, Integer>> entries = h.entrySet();
//        for (Map.Entry<Integer, Integer> entry : entries) {
//
//        }
//        Iterator<Integer> iterator1 = h.keySet().iterator();
//
//        while (iterator1.hasNext()) {
//            Integer next = iterator1.next();
//            if(1==next) {
//                iterator1.remove();
//                System.out.println("del="+next);
//            }
//        }
//        for (Map.Entry<Integer, Integer> integerIntegerEntry : h.entrySet()) {
//            System.out.println(integerIntegerEntry.getKey()+":"+integerIntegerEntry.getValue());
//        }

    }
    static void getM(){
        new taaa();
    }

}
